package com.dalin.platform.etl.service.imple;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;

import com.dalin.common.pager.PageInfo;
import com.dalin.common.utils.StringUtils;
import com.dalin.framework.dao.ConnectFactory;
import com.dalin.framework.dao.DbConn;
import com.dalin.framework.service.imple.FrameServiceImple;
import com.dalin.framework.vos.ColumnBaseInfoVo;
import com.dalin.framework.vos.JdbcVo;
import com.dalin.platform.etl.condition.EtlColumnInfoCondition;
import com.dalin.platform.etl.condition.EtlColumnViewCondition;
import com.dalin.platform.etl.condition.EtlDatabaseInfoCondition;
import com.dalin.platform.etl.condition.EtlTableInfoCondition;
import com.dalin.platform.etl.model.EtlColumnInfoEntity;
import com.dalin.platform.etl.model.EtlColumnViewEntity;
import com.dalin.platform.etl.model.EtlDatabaseInfoEntity;
import com.dalin.platform.etl.model.EtlTableInfoEntity;
import com.dalin.platform.etl.service.EtlService;
import com.dalin.platform.etl.vo.EtlColumnInfoVo;
import com.dalin.platform.etl.vo.EtlColumnViewVo;
import com.dalin.platform.etl.vo.EtlDatabaseInfoVo;
import com.dalin.platform.etl.vo.EtlTableInfoVo;
import com.dalin.platform.loa.LoaConst;
import com.dalin.platform.pub.PlatContext;
/*****************************************************************************
 * @content: ＥＴＬ数据通用接口实现类                                                                                                   *
 * @author : 那建林                                                                                                                                 *
 * @crtDate: 2010-11-25                                                     *
 ****************************************************************************/
public class EtlServiceImple extends FrameServiceImple implements EtlService {
	public PageInfo queryEtlDatabaseInfos(EtlDatabaseInfoCondition cond)throws Exception {
        PageInfo pageInfo = queryPageInfoByCond(cond.prepareParams());
        List<EtlDatabaseInfoEntity> entyList = pageInfo.getDataList();
        List<EtlDatabaseInfoVo> voList = new ArrayList<EtlDatabaseInfoVo>();
        EtlDatabaseInfoVo vo = null;
        for (EtlDatabaseInfoEntity enty : entyList) {
            vo = new EtlDatabaseInfoVo();
            vo.setDatabaseId(enty.getDatabaseId());
            vo.setHostIp(enty.getHostIp());
            vo.setDatabaseName(enty.getDatabaseName());
            vo.setDatabaseComment(enty.getDatabaseComment());
            vo.setUserName(enty.getUserName());
        	vo.setDatabaseTypeName(LoaConst.findItemName(
        			LoaConst.DIC_TYPE_CODE_ARRAY[1], enty.getDatabaseType()+""));
            voList.add(vo);
        }
        pageInfo.setDataList(voList);
        return pageInfo;
    }

    public EtlDatabaseInfoVo findEtlDatabaseInfoById(Long id)throws Exception {
        EtlDatabaseInfoEntity enty = (EtlDatabaseInfoEntity) getDao().findObjById(EtlDatabaseInfoEntity.class, id);
        EtlDatabaseInfoVo vo = new EtlDatabaseInfoVo();
        vo.setDatabaseId(enty.getDatabaseId());
        vo.setHostIp(enty.getHostIp());
        vo.setPort(enty.getPort());
        vo.setDatabaseName(enty.getDatabaseName());
        vo.setDatabaseComment(enty.getDatabaseComment());
        vo.setUserName(enty.getUserName());
        vo.setUserPswd(enty.getUserPswd());
    	vo.setDatabaseType(enty.getDatabaseType());
    	vo.setDatabaseDriver(enty.getDatabaseDriver());
    	vo.setRemark(enty.getRemark());
        return vo;
    }


    public void addEtlDatabaseInfo(EtlDatabaseInfoVo vo)throws Exception {
        EtlDatabaseInfoEntity enty = new EtlDatabaseInfoEntity();
        enty = getEtlDatabaseInfoEntityValue(enty, vo);
        enty.setCreateDate(new Date());
        getDao().createObj(enty);
    }

    /*************************************************************************
     * @content: 方法注释信息
     * @param  : EtlDatabaseInfoVo vo
     * @return : void
     * @author : 那建林
     * @crtDate: 2010-11-25
     * @modDate: 2010-11-25
     */
    public void modifyEtlDatabaseInfo(EtlDatabaseInfoVo vo)throws Exception {
        Long id = vo.getDatabaseId();
        EtlDatabaseInfoEntity enty = (EtlDatabaseInfoEntity) getDao()
        		.findObjById(EtlDatabaseInfoEntity.class, id);
        enty = getEtlDatabaseInfoEntityValue(enty, vo);
        getDao().updateObj(enty);
    }

    /*************************************************************************
     * @content: 方法注释信息
     * @param  : Long[] idArray
     * @return : void
     * @author : 那建林
     * @crtDate: 2010-11-25
     * @modDate: 2010-11-25
     */
    public void delEtlDatabaseInfosByIds(Long[] idArray)throws Exception {
        getDao().deleteObjs(EtlDatabaseInfoEntity.class, idArray);
    }

    private EtlDatabaseInfoEntity getEtlDatabaseInfoEntityValue(EtlDatabaseInfoEntity enty, EtlDatabaseInfoVo vo) {
    	enty.setHostIp(vo.getHostIp());
    	enty.setPort(vo.getPort());
    	enty.setDatabaseComment(vo.getDatabaseComment());
    	enty.setDatabaseName(vo.getDatabaseName());
    	enty.setUserName(vo.getUserName());
    	enty.setUserPswd(vo.getUserPswd());
    	enty.setDatabaseType(vo.getDatabaseType());
    	enty.setDatabaseDriver(vo.getDatabaseDriver());
    	enty.setRemark(vo.getRemark());
    	return enty;
    }

	public void synDbInfoStructure(Long id) throws Exception {
		 EtlDatabaseInfoEntity enty = (EtlDatabaseInfoEntity) getDao()
		 		.findObjById(EtlDatabaseInfoEntity.class, id);
		 JdbcVo jdbc = getJdbcVoFromDatabaseInfoEnty(enty);
		 DbConn conn = ConnectFactory.getConnectionInstance(jdbc);
		 Set<String> tnSet = conn.queryTables();
		 List<EtlTableInfoEntity> oriTableList = enty.getTableInfoEntitys();
		 List<EtlTableInfoEntity> willDelTableList = new 
		 ArrayList<EtlTableInfoEntity>(oriTableList);
		 
		 //增加
		 for (String tableName : tnSet) {
			 EtlTableInfoEntity tableEnty = null;
			 for (EtlTableInfoEntity oriTable : oriTableList) {
				 if (tableName.toUpperCase().trim().equals(
						 oriTable.getTableName().toUpperCase().trim())) {
					 tableEnty = oriTable;
					 willDelTableList.remove(oriTable);
					 break;
				 }
			 }
			 if (tableEnty == null) {
				 tableEnty = new EtlTableInfoEntity();
			 }
			 tableEnty.setDatabaseId(enty.getDatabaseId());
			 tableEnty.setTableName(tableName);
			 getDao().createOrUpdateObj(tableEnty);
			 //字段先删除,后增加修改
			 Set<ColumnBaseInfoVo> columnInfoList = conn
			 		.queryColumnInfosByTable(tableName);
			 List<EtlColumnInfoEntity> oriColumnList = tableEnty.getEtlColumnInfoEntitys();
			 List<EtlColumnInfoEntity> willDelColumnList = new ArrayList<EtlColumnInfoEntity>(oriColumnList);
			 for (ColumnBaseInfoVo columnInfo : columnInfoList) {
				 EtlColumnInfoEntity columnEnty = null;
				 for (EtlColumnInfoEntity oriColumn : oriColumnList) {
					 if (columnInfo.getColumnName().toUpperCase().trim().equals(
							 oriColumn.getColumnName().toUpperCase().trim())) {
						 columnEnty = oriColumn;
						 willDelColumnList.remove(oriColumn);
						 break;
					 }
				 }
				 if (columnEnty == null) {
					 columnEnty = new EtlColumnInfoEntity();
				 }
				 columnEnty.setTableId(tableEnty.getTableId());
				 columnEnty.setIsPrimaryKey(columnInfo.isPrimaryKey());
				 columnEnty.setColumnName(columnInfo.getColumnName());
				 columnEnty.setColumnType(Integer.parseInt(LoaConst.findItemCode(LoaConst
						 .DIC_TYPE_CODE_ARRAY[1], columnInfo.getColumnType())));
				 columnEnty.setColumnLength(columnInfo.getColumnLength());
				 columnEnty.setNullable(columnInfo.getNullable());
				 columnEnty.setDecimalDigits(columnInfo.getDecimalDigits());
				 getDao().createOrUpdateObj(columnEnty);
			 }
			 for (EtlColumnInfoEntity fuck : willDelColumnList) {
				 getDao().deleteObj(fuck);
			 }
		 }
		 for (EtlTableInfoEntity oriTable : willDelTableList) {
			 getDao().deleteObjs(oriTable.getEtlColumnInfoEntitys());
			 getDao().deleteObj(oriTable);
		 }
	}
	
	public boolean testDatabaseConn(EtlDatabaseInfoVo vo) throws Exception {
		JdbcVo jdbc = new JdbcVo();
		jdbc.setHostIp(vo.getHostIp());          // 主机IP
		jdbc.setPort(vo.getPort() + "");            // 端口号
		jdbc.setDbName(vo.getDatabaseName());      // 数据库名
		jdbc.setDriverClassName(LoaConst.findItemName(
				LoaConst.DIC_TYPE_CODE_ARRAY[0], vo.getDatabaseDriver()+""));
		jdbc.setUserName(vo.getUserName());        // 用户名
		jdbc.setUserPswd(vo.getUserPswd());        // 密码
		DbConn conn = ConnectFactory.getConnectionInstance(jdbc);
		boolean sucs = conn.testConnDatabase();
		return sucs;
	}
	
	
	
	
	
	
	
	
	

	

	public void addEtlTableInfo(EtlTableInfoVo vo) throws Exception {
		EtlTableInfoEntity enty = new EtlTableInfoEntity();
		enty = getEtlTableInfoEntityValue(enty, vo);
    	JdbcVo jdbc = getJdbcVoFromDatabaseInfoEnty(enty.getDatabaseInfoEntity());
		DbConn conn = ConnectFactory.getConnectionInstance(jdbc);
		conn.executeUpdate("CREATE TABLE "
				+ enty.getTableName() + "("
				+ enty.getTableName() + "_ID NUMBER(16))");
        
		getDao().createObj(enty);
	}

	public void delEtlTableInfosByIds(Long[] idArray) throws Exception {
		for (Long id : idArray) {
			EtlTableInfoEntity enty = (EtlTableInfoEntity) getDao()
					.findObjById(EtlTableInfoEntity.class, id);
			JdbcVo jdbc = getJdbcVoFromDatabaseInfoEnty(enty.getDatabaseInfoEntity());
			DbConn conn = ConnectFactory.getConnectionInstance(jdbc);
			conn.executeUpdate("DROP TABLE " + enty.getTableName());
		}
		getDao().deleteObjs(EtlTableInfoEntity.class, idArray);
	}

	public EtlTableInfoVo findEtlTableInfoById(Long id) throws Exception {
		EtlTableInfoEntity enty = (EtlTableInfoEntity) getDao()
				.findObjById(EtlTableInfoEntity.class, id);
        EtlTableInfoVo vo = new EtlTableInfoVo();
        vo.setTableId(enty.getTableId()); // 
        vo.setDatabaseId(enty.getDatabaseId()); //
        vo.setTableName(enty.getTableName()); // 
        vo.setTableComment(enty.getTableComment()); // 
        vo.setRemark(enty.getRemark()); // 
        return vo;
	}

	public void modifyEtlTableInfo(EtlTableInfoVo vo) throws Exception {
		Long id = vo.getTableId();
        EtlTableInfoEntity enty = (EtlTableInfoEntity) getDao()
        		.findObjById(EtlTableInfoEntity.class, id);
//        if (!enty.getDatabaseId().equals(vo.getDatabaseId())) {
//        	throw new RuntimeException("不允许修改所属数据库");
//        }
        if (!enty.getTableName().equals(vo.getTableName())) {
        	JdbcVo jdbc = getJdbcVoFromDatabaseInfoEnty(enty.getDatabaseInfoEntity());
    		DbConn conn = ConnectFactory.getConnectionInstance(jdbc);
    		conn.executeUpdate("ALTER TABLE "
    				+ enty.getTableName() + " rename to "
    				+ vo.getTableName()+ ";");
        }
        enty = getEtlTableInfoEntityValue(enty, vo);
        getDao().updateObj(enty);
	}

	public PageInfo queryEtlTableInfos(EtlTableInfoCondition cond)
			throws Exception {
		PageInfo pageInfo = queryPageInfoByCond(cond.prepareParams());
        List<EtlTableInfoEntity> entyList = pageInfo.getDataList();
        List<EtlTableInfoVo> voList = new ArrayList<EtlTableInfoVo>();
        EtlTableInfoVo vo = null;
        for (EtlTableInfoEntity enty : entyList) {
            vo = new EtlTableInfoVo();
	        vo.setTableId(enty.getTableId()); // 
	        vo.setTableName(enty.getTableName()); // 
	        vo.setTableComment(enty.getTableComment()); // 
	        vo.setRemark(enty.getRemark()); // 
	        EtlDatabaseInfoEntity dbEnty = enty.getDatabaseInfoEntity();
	        vo.setDatabaseName(dbEnty.getDatabaseName());
	        vo.setUserName(dbEnty.getUserName());
	        vo.setDatabaseTypeName(LoaConst.findItemName(
	        		LoaConst.DIC_TYPE_CODE_ARRAY[1], dbEnty.getDatabaseType()+""));
	        voList.add(vo);
        }
        pageInfo.setDataList(voList);
        return pageInfo;
	}
	
	
	private EtlTableInfoEntity getEtlTableInfoEntityValue(EtlTableInfoEntity enty, EtlTableInfoVo vo) {
        enty.setDatabaseId(vo.getDatabaseId()); // 
        enty.setTableName(vo.getTableName().trim().toUpperCase()); // 
        enty.setTableComment(vo.getTableComment()); // 
        enty.setRemark(vo.getRemark()); // 
        return enty;
    }
	
	private JdbcVo getJdbcVoFromDatabaseInfoEnty(EtlDatabaseInfoEntity enty) {
		JdbcVo jdbc = new JdbcVo();
		 jdbc.setHostIp(enty.getHostIp());          // 主机IP
		 jdbc.setPort(enty.getPort() + "");            // 端口号
		 jdbc.setDbName(enty.getDatabaseName());      // 数据库名
//		 jdbc.setDriverClassName(LoaConst.findItemName(
//				LoaConst.DIC_TYPE_CODE_ARRAY[0], enty.getDatabaseDriver()));
		 jdbc.setDriverClassName("oracle.jdbc.driver.OracleDriver");
		 jdbc.setUserName(enty.getUserName());        // 用户名
		 jdbc.setUserPswd(enty.getUserPswd());        // 密码
		return jdbc;
	}
	
	
	
	
	
	
	public PageInfo queryEtlColumnInfos(EtlColumnInfoCondition cond) throws Exception {
        PageInfo pageInfo = queryPageInfoByCond(cond.prepareParams());
        List<EtlColumnInfoEntity> entyList = pageInfo.getDataList();
        List<EtlColumnInfoVo> voList = new ArrayList<EtlColumnInfoVo>();
        EtlColumnInfoVo vo = null;
        for (EtlColumnInfoEntity enty : entyList) {
            vo = new EtlColumnInfoVo(); // 
            vo.setTableId(enty.getTableId());
	        vo.setColumnComment(enty.getColumnComment()); // 
	        vo.setColumnLength(enty.getColumnLength()); // 
	        vo.setColumnId(enty.getColumnId()); // 
	        vo.setColumnName(enty.getColumnName()); // 
	        vo.setColumnType(enty.getColumnType());
	        vo.setColumnTypeName(LoaConst.findItemName(LoaConst
	        		.DIC_TYPE_CODE_ARRAY[1], enty.getColumnType()+"")); // 
	        vo.setNullable(enty.getNullable());
	        vo.setNullableName(LoaConst.findItemName(LoaConst
	        		.DIC_TYPE_CODE_ARRAY[2], enty.getNullable()+"")); //
	        vo.setDecimalDigits(enty.getDecimalDigits());
	        vo.setRemark(enty.getRemark());
	        voList.add(vo);
        }
        pageInfo.setDataList(voList);
        return pageInfo;
    }

	
    public EtlColumnInfoVo findEtlColumnInfoById(Long id)throws Exception {
        EtlColumnInfoEntity enty = (EtlColumnInfoEntity) getDao().findObjById(EtlColumnInfoEntity.class, id);
        EtlColumnInfoVo vo = new EtlColumnInfoVo();
        vo.setColumnType(enty.getColumnType()); // 
        vo.setTableId(enty.getTableId()); // 
        vo.setRemark(enty.getRemark()); // 
        vo.setColumnComment(enty.getColumnComment()); // 
        vo.setColumnLength(enty.getColumnLength()); // 
        vo.setColumnId(enty.getColumnId()); // 
        vo.setColumnName(enty.getColumnName()); // 
        vo.setNullable(enty.getNullable()); // 
        return vo;
    }

    
    public void addEtlColumnInfo(EtlColumnInfoVo vo)throws Exception {
        EtlColumnInfoEntity enty = new EtlColumnInfoEntity();
        enty = getEtlColumnInfoEntityValue(enty, vo);
        EtlTableInfoEntity tableEnty = (EtlTableInfoEntity) getDao()
        		.findObjById(EtlTableInfoEntity.class, vo.getTableId());
        JdbcVo jdbc = getJdbcVoFromDatabaseInfoEnty(tableEnty.getDatabaseInfoEntity());
		DbConn conn = ConnectFactory.getConnectionInstance(jdbc);
		conn.addColumn(tableEnty.getTableName(), 
				enty.getColumnName(), 
				LoaConst.findItemName(LoaConst.DIC_TYPE_CODE_ARRAY[1],
						enty.getColumnType()+""),
				enty.getColumnLength(), 
				enty.getNullable() == 1 ? true : false);
        getDao().createObj(enty);
    }

    
    public void modifyEtlColumnInfo(EtlColumnInfoVo vo)throws Exception {
        Long id = vo.getColumnId();
        EtlColumnInfoEntity enty = (EtlColumnInfoEntity) getDao()
        		.findObjById(EtlColumnInfoEntity.class, id);
        EtlTableInfoEntity tableEnty = enty.getTableInfoEntity();
        JdbcVo jdbc = getJdbcVoFromDatabaseInfoEnty(
        		tableEnty.getDatabaseInfoEntity());
		DbConn conn = ConnectFactory.getConnectionInstance(jdbc);
		conn.alterColumn(tableEnty.getTableName(), 
				enty.getColumnName(),
				vo.getColumnName(),
				LoaConst.findItemName(LoaConst.DIC_TYPE_CODE_ARRAY[1],
						enty.getColumnType()+""),
				enty.getColumnLength(), 
				enty.getNullable() == 1 ? true : false);
        enty = getEtlColumnInfoEntityValue(enty, vo);
        getDao().updateObj(enty);
    }

    public void delEtlColumnInfosByIds(Long[] idArray) throws Exception {
    	for (Long id : idArray) {
    		EtlColumnInfoEntity enty = (EtlColumnInfoEntity) getDao()
		    		.findObjById(EtlColumnInfoEntity.class, id);
		    EtlTableInfoEntity tableEnty = enty.getTableInfoEntity();
		    JdbcVo jdbc = getJdbcVoFromDatabaseInfoEnty(
		    		tableEnty.getDatabaseInfoEntity());
			DbConn conn = ConnectFactory.getConnectionInstance(jdbc);
			conn.dropColumn(tableEnty.getTableName(), enty.getColumnName());
    		getDao().deleteObj(enty);
    	}
    }

    private EtlColumnInfoEntity getEtlColumnInfoEntityValue(EtlColumnInfoEntity enty, EtlColumnInfoVo vo) {
        enty.setColumnType(vo.getColumnType()); // 
        enty.setTableId(vo.getTableId()); // 
        enty.setRemark(vo.getRemark()); // 
        enty.setColumnComment(vo.getColumnComment()); // 
        enty.setColumnLength(vo.getColumnLength()); // 
        enty.setColumnId(vo.getColumnId()); // 
        enty.setColumnName(vo.getColumnName()); // 
        enty.setNullable(vo.getNullable()); // 
        return enty;
    }
    
    
    
    public PageInfo queryEtlColumnViews(EtlColumnViewCondition cond)throws Exception {
        PageInfo pageInfo = queryPageInfoByCond(cond.prepareParams());
        List<EtlColumnViewEntity> entyList = pageInfo.getDataList();
        List<EtlColumnViewVo> voList = new ArrayList<EtlColumnViewVo>();
        EtlColumnViewVo vo = null;
        for (EtlColumnViewEntity enty : entyList) {
            vo = new EtlColumnViewVo();
	        vo.setColumnViewId(enty.getColumnViewId()); // 
	        vo.setDicTypeCode(enty.getDicTypeCode()); // 
	        vo.setUsable(enty.getUsable()); // 
	        vo.setColumnId(enty.getColumnId()); // 
	        vo.setRemark(enty.getRemark()); // 
	        vo.setDisplayWay(enty.getDisplayWay()); // 
	        voList.add(vo);
        }
        pageInfo.setDataList(voList);
        return pageInfo;
    }

    public EtlColumnViewVo findEtlColumnViewById(Long id)throws Exception {
        EtlColumnViewEntity enty = (EtlColumnViewEntity) getDao()
        		.findObjById(EtlColumnViewEntity.class, id);
        EtlColumnViewVo vo = new EtlColumnViewVo();
        vo.setColumnViewId(enty.getColumnViewId());
    	vo.setDicTypeCode(enty.getDicTypeCode());
    	vo.setDisplayWay(enty.getDisplayWay());
    	vo.setDisplayWayName(LoaConst.findItemName(
    			LoaConst.DIC_TYPE_CODE_ARRAY[5], enty.getDisplayWay()+""));
    	vo.setUsable(enty.getUsable());
    	vo.setUsableName(LoaConst.findItemName(
    			LoaConst.DIC_TYPE_CODE_ARRAY[3], enty.getUsable()+""));
        vo.setColumnId(enty.getColumnId()); // 
        vo.setRemark(enty.getRemark()); // 
        return vo;
    }
    
    public EtlColumnViewVo findEtlColumnViewByColumnId(Long columnId)throws Exception {
    	EtlColumnViewVo vo = new EtlColumnViewVo();
    	 vo.setColumnId(columnId); // 
    	List<EtlColumnViewEntity> dataList = PlatContext.getDao()
				.queryEqualObjs(EtlColumnViewEntity.class,
							"columnId", columnId);
		if (StringUtils.isBlank(dataList)) return vo;
		EtlColumnViewEntity enty = dataList.get(0);
        vo.setColumnViewId(enty.getColumnViewId());
    	vo.setDicTypeCode(enty.getDicTypeCode());
    	vo.setDisplayWay(enty.getDisplayWay());
    	vo.setDisplayWayName(LoaConst.findItemName(
    			LoaConst.DIC_TYPE_CODE_ARRAY[5], enty.getDisplayWay()+""));
    	vo.setUsable(enty.getUsable());
    	vo.setUsableName(LoaConst.findItemName(
    			LoaConst.DIC_TYPE_CODE_ARRAY[3], enty.getUsable()+""));
        vo.setRemark(enty.getRemark()); // 
        return vo;
    }

    public Long addEtlColumnView(EtlColumnViewVo vo)throws Exception {
        EtlColumnViewEntity enty = new EtlColumnViewEntity();
        enty = getEtlColumnViewEntityValue(enty, vo);
        getDao().createObj(enty);
        return enty.getColumnViewId();
    }

  
    public void modifyEtlColumnView(EtlColumnViewVo vo)throws Exception {
        Long id = vo.getColumnViewId();
        EtlColumnViewEntity enty = (EtlColumnViewEntity) getDao().findObjById(EtlColumnViewEntity.class, id);
        enty = getEtlColumnViewEntityValue(enty, vo);
        getDao().updateObj(enty);
    }

    public void delEtlColumnViewsByIds(Long[] idArray)throws Exception {
        getDao().deleteObjs(EtlColumnViewEntity.class, idArray);
    }

    private EtlColumnViewEntity getEtlColumnViewEntityValue(EtlColumnViewEntity enty, EtlColumnViewVo vo) {
        enty.setDicTypeCode(vo.getDicTypeCode()); // 
        enty.setUsable(vo.getUsable()); // 
        enty.setColumnId(vo.getColumnId()); // 
        enty.setRemark(vo.getRemark()); // 
        enty.setDisplayWay(vo.getDisplayWay()); // 
        return enty;
    }
}
